@extends('master')
@section('title', 'Home')
@section('content')
{{---------------------- R E L A T O S ----------------------}}
@if( !$relatos->isEmpty() )
<div class="container-fluid">
    <div class="row">
        <div class="col-lg-12">
            <h3>Relatos</h3>
        </div>
    </div>
    
    {{---------------------- Relato principal ----------------------}}
    <?php $relatoPrincipal = $relatos->shift(); #Get and remove the first item from the collection. ?>
    <div class="row">
        <div class="col-md-12 text-center">
            @if( $image = $relatoPrincipal->getFirstImage() )
                <a href="{{ URL::route('relato', ['slug' => $relatoPrincipal->slug, 'id' => $relatoPrincipal->id]) }}">
                    <img class="lazy img-full" data-original="{{ URL::to($image->img->url('rel_main')) }}" alt="{{ $image->title }}"/>
                </a>
            @endif
            <h5>{{ Str::upper($relatoPrincipal->getFirstTagName()) }}</h5>
            <h1><a href="{{ URL::route('relato', ['slug' => $relatoPrincipal->slug, 'id' => $relatoPrincipal->id]) }}">{{$relatoPrincipal->titulo}}</a></h1>
            <br>
        </div>
    </div>
    {{---------------------- FIN Relato principal ----------------------}}
    
    {{---------------------- Relatos secundarios ----------------------}}
        @foreach($relatos as $i => $relato)
        @if($i%3 == 0)
            <div class="row">
        @endif
            <div class="col-md-4 col-sm-6 text-center">
                @if( $image = $relato->getFirstImage() )
                    <a href="{{ URL::route('relato', ['slug'=>$relato->slug, 'id'=>$relato->id]) }}">
                        <img class="lazy img-full" data-original="{{ URL::to($image->img->url('rel_mini')) }}" alt="{{ $image->title }}"/>
                    </a>
                @endif
                <h5>{{ Str::upper($relato->getFirstTagName()) }}</h5>
                <h3><a href="{{ URL::route('relato', ['slug'=>$relato->slug, 'id'=>$relato->id]) }}">{{$relato->titulo}}</a></h3>
                <br>
            </div>
        @if($i%3 == 2)
            </div>
        @endif
        @endforeach
    {{---------------------- FIN Relatos secundarios ----------------------}}
</div>
<hr>
@endif
{{---------------------- F I N   R E L A T O S ----------------------}}


{{------------------------ A P A R M E N T --------------------------}}
@if( ! is_null( $apartment = $apartment->first() ) )
        <div class="container-fluid">
            <div class="row">
                <div class="col-md-3">
                    <h3>{{ HTML::linkRoute('apartment', 'The Apartment', ['fecha' => $apartment->fecha->toDateString(), 'id' => $apartment->id])}}</h3>
                </div>
                <div class="col-md-9">
                    <br>
                    <p><b>{{ $apartment->fecha_formatted() }}</b><br>{{ $apartment->lugar }} {{ Str::limit($apartment->texto, 100, '...') }}</p>
                    <br>
                </div>
            </div>
        </div>
        <hr>
@endif
{{--------------------- Fin The Apartment ---------------------------}}


{{------------------------ O B J E T O S ----------------------------}}
@if( !$objetos->isEmpty() )
        <div class="container-fluid">
            <div class="row">
                <div class="col-lg-12">
                    <h3>Objetos</h3>
                </div>
                @foreach($objetos as $objeto)
                    <div class="col-md-3 col-sm-6 text-center">
                        {{-- Si no tiene imagenes no imprime --}}
                        @if( $image = $objeto->getFirstImage() )
                            <a href="{{ URL::route('objeto', ['slug'=>$objeto->slug, 'id'=>$objeto->id]) }}">
                                <img class="lazy img-full" data-original="{{ URL::to($image->img->url('obj_mini')) }}" alt="{{ $image->title }}"/>
                            </a>
                        @endif
                        <h5>{{ Str::upper($objeto->getFirstTagName()) }}</h5>
                        <h4><a href="{{ URL::route('objeto', ['slug'=>$objeto->slug, 'id'=>$objeto->id]) }}">{{$objeto->nombre}}</a></h4>
                        <br>
                    </div>
                @endforeach
            </div> {{-- .row --}}
        </div> {{-- .container-fluid --}}
@endif
{{----------------------- F I N   O B J E T O S ----------------------}}
@stop